/*
 * SRMI (an easy-to-use zero-code remoting library for Java)
 * Copyright (C) 2007  Mohammad Nabil Hussein
 * mohammad (dot) nabil (dot) h (at) gmail (dot) com
 *
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Lesser General Public
 * License as published by the Free Software Foundation; either
 * version 2.1 of the License, or (at your option) any later version.
 *
 * This library is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public
 * License along with this library; if not, write to the Free Software
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
 */

package SRMI.Tests;

import SRMI.RemotingServices.ClientUtils;
import SRMI.RemotingServices.CommonUtils;
import SRMI.RemotingServices.PassableByRemote;

@PassableByRemote
public class MyIndirectClient
{
    
    /** Creates a new instance of MyIndirectClient */
    public MyIndirectClient()
    {
    }
    
    private MyServer server;
    
    public MyIndirectClient(MyServer server)
    {
        this.server = server;
    }
    
    public void CallMe(MyClient koko)
    {
        System.out.println("calling MyClient");
        koko.CallingYou();
    }
    
    private void Test()
    {
        server.CallMe(this);
        server.GetMyClient().CallingYou();
    }
    
    public static void main(String[] args) throws Exception
    {        
        System.out.println("Usage:\njava -Dsrmi.basedir=$(pwd) -Dsrmi.jar.path=../../dist/SRMI.jar -classpath .:../../dist/lib/tools.jar:../../../Orchestra/dist/lib/log4j-1.2.14.jar SRMI.Tests.MyIndirectClient");
        
        new MyIndirectClient((MyServer)
        ClientUtils.getRemoteObject(MyServer.class,
        CommonUtils.detectExternalInterfaceIP(),ClientUtils.ANY_INSTANCE))
        .Test();
    }

    
}
